var Carorder = require("../../../class/admin/carorder.c");
module.exports = {
    prefix: "/admin/carorder/",
    get:{
    	'list':{
             des: {
                name: "Carorderlist",
                content: "房车订单列表",
                params: [
                    {
                        key:'page',
                        type:'int'
                    },
                    {
                        key:'status',
                        type:'int'
                    }
                ]
            },
            method: function* () {
                var self = this;
                try {
                    var receive_data = self.request.query;
                    var data = yield new Carorder(receive_data,self.session.admin).list();
                    self.body = data;
                } catch (e) {
                    self.body = printError(e);
                };
            }
        },
        'count':{
	    	 des: {
                name: "Carorderlist",
                content: "房车订单统计",
                params: [
	                {
	                	key:'status',
	                	type:'int'
	                }
                ]
    		},
            method: function* () {
            	var self = this;
            	try {
                    var receive_data = self.request.query;
	            	var data = yield new Carorder(receive_data,self.session.admin).count();
                	self.body = data;
                } catch (e) {
                    self.body = printError(e);
                };
            }
    	}
    },
    post: {
        'update':{
	    	 des: {
                name: "updateCarorder",
                content: "修改房车订单状态",
                params: [
	                {
	                	key:'statue',
	                	type:'int'
	                }
                ]
    		},
            method: function* () {
            	var self = this;
            	try {
                    /*var receive_data = self.request.body;
	            	var data = yield new Carorder(receive_data,self.session.admin).update();*/
                	self.body = {};
                } catch (e) {
                    self.body = printError(e);
                };
            }
    	}
    },
    delete:{
    	'delete/:_id':{
    		 des: {
                name: "postDelete",
                content: "删除指定房车订单",
                params: [
                    {
                        params: "_id",
                        type: "string"
                    }
                ]
            },
            method: function* () {
                var self = this;
                try {
                   	var data = yield new Carorder(self.params,self.session.admin).delete();
                    self.body = data;
                } catch (e) {
                    self.body = printError(e);
                };
            }
    	}
    }
}
